/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bea.cliente.gui.builders;

import bea.cliente.gui.styles.ButtonStyles;
import bea.cliente.gui.styles.WindowStyles;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.builder.PanelBuilder;
import de.lessvoid.nifty.controls.button.builder.ButtonBuilder;
import de.lessvoid.nifty.controls.window.builder.WindowBuilder;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.tools.Color;

/**
 *
 * @author Ivan
 */
public class AudioOptionsWindowBuilder {

    public static String WINDOW_ID = "audioOptionsWindow";
    public static String WIDTH = "300px";
    public static String HEIGHT = "400px";
    public static String TITLE = "Audio";

    public static Element build(Nifty nifty, Screen screen, Element parent) {
        Element audioOptionsWindow = new WindowBuilder(WINDOW_ID, TITLE) {

            {
                style(WindowStyles.BLACK_STYLE);
                width(WIDTH);
                height(HEIGHT);
                parameter("hideOnClose", "true");
                parameter("closeable", "true");
                parameter("visible", "false");
                parameter("controller", "bed.cliente.gui.controllers.AudioOptionsWindowController");
            }
        }.build(nifty, screen, parent);

        // recupera o panel de conteudo da janela
        Element windowContent = audioOptionsWindow.findElementByName("#window-content");
        // adiciona ao panel de conteudo os demais itens da janel
        windowContent.add(new PanelBuilder() {

            {
                width(percentage(100));
                height(percentage(100));
                childLayoutVertical();


                panel(new PanelBuilder() {

                    {
                        height(percentage(90));
                        width(percentage(100));
                        color(Color.randomColor());
                        childLayoutHorizontal();
                    }
                });

                panel(new PanelBuilder() {

                    {
                        width(percentage(100));
                        height(percentage(10));
                        childLayoutHorizontal();

                        // painel contendo o botao "OK"
                        panel(new PanelBuilder() {

                            {
                                height(percentage(100));
                                width(percentage(33));
                                childLayoutCenter();
                                alignCenter();
                                control(new ButtonBuilder("btnAudioOptionsOK", "OK") {

                                    {
                                        style(ButtonStyles.BED_BASIC);
                                        alignCenter();
                                        valignCenter();
                                        width("80px");
                                    }
                                });
                            }
                        });

                        // painel contendo o botao "APPLY"
                        panel(new PanelBuilder() {

                            {
                                height(percentage(100));
                                width(percentage(33));
                                childLayoutCenter();
                                alignCenter();
                                control(new ButtonBuilder("btnAudioOptionsApply", "APPLY") {

                                    {
                                        style(ButtonStyles.BED_BASIC);
                                        alignCenter();
                                        valignCenter();
                                        width("80px");
                                    }
                                });
                            }
                        });

                        // painel contendo o botao "CANCEL"
                        panel(new PanelBuilder() {

                            {
                                height(percentage(100));
                                width(percentage(33));
                                childLayoutCenter();
                                alignCenter();
                                control(new ButtonBuilder("btnAudioOptionsCancel", "CANCEL") {

                                    {
                                        alignCenter();
                                        valignCenter();
                                        width("80px");
                                    }
                                });
                            }
                        });
                    }
                });
            }
        }.build(nifty, screen, windowContent));

        return audioOptionsWindow;
    }
}
